<div id="calendarpreinfo">
	<?php $prevmonth = clone $this->date_monthview; $prevmonth->addMonth(-1); $nextmonth = clone $this->date_monthview; $nextmonth->addMonth(1); ?>
	<a href="<?=$this->url(array('year'=>$prevmonth->get(Zend_Date::YEAR_8601),'month'=>$prevmonth->get(Zend_Date::MONTH)),'calendar/display',true);?>"><img src="<?=$this->url(array(),'default',true);?>public/images/arrow_left.png" alt="Vorheriger Monat" /></a>&nbsp;
	<?=$this->date_monthview->get(Zend_Date::MONTH_NAME);?> <?=$this->date_monthview->get(Zend_Date::YEAR_8601);?>&nbsp;
	<a href="<?=$this->url(array('year'=>$nextmonth->get(Zend_Date::YEAR_8601),'month'=>$nextmonth->get(Zend_Date::MONTH)),'calendar/display',true);?>"><img src="<?=$this->url(array(),'default',true);?>public/images/arrow_right.png" alt="Nächster Monat" /></a>
</div>
<table class="bigcalendar">
	<thead>
		<tr>
			<th class="column_kw">KW</th>
			<th>Montag</th>
			<th>Dienstag</th>
			<th>Mittwoch</th>
			<th>Donnerstag</th>
			<th>Freitag</th>
			<th>Samstag</th>
			<th>Sonntag</th>
		</tr>
	</thead>
	<tbody>
	<?php
        $lastkw = 0;
        $monthdays = $this->date_monthview->get(Zend_Date::MONTH_DAYS);
        for ($i = 0; $i < $monthdays; $i++)
        {
            $tmp_date = clone $this->date_monthview;
            $tmp_date->addDay($i);
            if ($tmp_date->get(Zend_Date::WEEK) != $lastkw)
            {
                ?>
                <tr>
            		<td class="column_kw"><?=$tmp_date->get(Zend_Date::WEEK);?></td>
                <?php
                $lastkw = $tmp_date->get(Zend_Date::WEEK);
            }
            if (0 == $i)
            {
                $weekday = $tmp_date->get(Zend_Date::WEEKDAY_8601) - 1;
                $lastmonth = clone $tmp_date;
                $lastmonth->addMonth(-1);
                $daysoflastmonth = $lastmonth->get(Zend_Date::MONTH_DAYS);
                for ($j = 0; $j < $weekday; $j++)
                {
                    ?>
                    <td class="inactive"><?=($daysoflastmonth - $weekday + $j + 1);?></td>
                    <?php
                }
            }
            
            $classes = array();
            if ($tmp_date->equals(7, Zend_Date::WEEKDAY_8601))
            {
                $classes[] = 'freeday';
            }
            if ($this->date_today->compareDate($tmp_date, Zend_Date::DATE_SHORT) == 0)
            {
                $classes[] = 'today';
            }
            ?>
            <td<?=(count($classes) > 0 ? ' class="' . implode(' ', $classes) . '"' : '');?>><?=$i+1;?><br /></td>
            <?php
            $wd = $tmp_date->get(Zend_Date::WEEKDAY_8601);
            if ($monthdays - 1 == $i)
            {
                for ($j = $tmp_date->get(Zend_Date::WEEKDAY_8601); $j < 7; $j++)
                {
                    ?>
                		<td class="inactive"><?=$j;?></td>
                    <?php
                }
                $wd = 7;
            }
            if (7 == $wd)
            {
                print '</tr>';
            }
        }
	?>
	</tbody>
</table>
Number of days of month: <?=$this->date_monthview->get(Zend_Date::MONTH_DAYS);?><br />
First day of month is an: <?=$this->date_monthview->get(Zend_Date::WEEKDAY);?>
